<?php
  
  require_once('./system/dbConnect.php');
  require_once('./system/myFunc.php');
  //连接数据库   
  connect();
  if(!empty($_FILES["pic"]["name"])){
    $pic = uploadfile('pic',UserPhotoPath,array('jpg','gif','png'));
  }
  else{
    $pic='';
  }
  $data = array(
    'uname' => trim($_POST['uname']),  
    'password' => $_POST['password'],
    'gender' => $_POST['gender'],
    'birthdate' => $_POST['birthdate'],
    'hobby' => implode($_POST['hobby'], ','),
    'degree' => $_POST['degree'],
    'intro' => $_POST['intro'],
    'pic'=>$pic
    );
  //执行SQL语句
  $result = add('users',$data);
  if(!$result){
    echo "注册失败！<br/>";
    echo "<a href='userReg.html'>返回</a>";   
  }else{    
  echo "注册成功！";
  echo "请使用<a href='./admin/login.html'>管理员登录</a>查看用户信息，";
  echo "或返回<a href='userReg.html'>注册</a>页面！";   
  }    
  
?>
